package org.apache.osgimaker.analyse.algorithm.util;


/**
 * Logical OR Operation on a sequence of {@link StringPattern StringPatterns}.
 * 
 */
public class OrStringPattern extends StringPatternSequence
{
  /**
   * Creates instance with specified patterns.
   */
  public OrStringPattern(StringPattern... pattern)
  {
    super(pattern);
  }

  /**
   * Return <code>true</code> if a pattern in the sequence returns 
   * <code>true</code>. Otherwise <code>false</code> is returned.
   */
  public boolean matches(String string)
  {
    boolean result = false;
    for (int i = 0, n = _patterns.size(); i < n; i++)
    {
      if (((StringPattern) _patterns.get(i)).matches(string))
      {
        result = true;
        break;
      }
    }
    return result;
  }

  protected String getOperatorSymbol()
  {
    return " ";
  }
}
